package com.lagou.service.Impl;

import com.lagou.base.StatusCode;
import com.lagou.dao.CourseContentDao;
import com.lagou.domain.Course_Section;
import com.lagou.service.CourseContentService;
import com.lagou.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("courseContentService")  //相当于配置了bean标签  id属性
public class CourseContentServiceImpl implements CourseContentService {

    @Autowired
    private CourseContentDao contentDao;

    @Override
    public String saveSection(Course_Section section) {
        //1.补全章节信息
        section.setStatus(2);//状态 0 隐藏,1 待更新,2 已发布
        String date = DateUtils.getDateFormart();
        section.setCreate_time(date);
        section.setUpdate_time(date);

        //2.调用dao
        int row = contentDao.saveSection(section);

        //3.根据是否插入成功,封装对应信息
        if(row > 0){
            //保存成功
            String result = StatusCode.SUCCESS.toString();
            return result;
        }else{
            String result = StatusCode.FAIL.toString();
            return result;
        }
    }
}
